<template>
  <div>
    首页
    <p>
      <button @click="changeUserInfo">改变用户信息</button>
      <button @click="fetchUserInfo">请求用户信息</button>
    </p>
  </div>
</template>

<script>
import { mapMutations } from 'vuex'
export default {
  methods: {
    ...mapMutations(['setUserInfo']),
    changeUserInfo() {
      this.setUserInfo({
        name: '四五六',
        age: 16
      })
      // this.$store.commit('setUserInfo', {name: '七八九', age: 19})
    },
    fetchUserInfo() {
      this.$store.dispatch('fetchUserInfo')
    }
  },
  mounted () {
    console.log(this.$store);
  }
}
</script>

<style scoped>
</style>